package com.mars.rabbitmq.normal;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author King
 * @create 2020/8/19 10:32
 */
@Data
@Slf4j
@Configuration
public class RabbitMqConfig {

    public static final String EXCHANGE = "marsExchange";
    public static final String QUEUE = "marsDevQueue";
    public static final String ROUTING_KEY = "marsDevRoutingKey";


    @Bean
    public DirectExchange kingExchange() {
        return new DirectExchange(EXCHANGE);
    }

    @Bean
    public Queue kingQueue() {
        return new Queue(QUEUE);
    }

    @Bean
    public Binding kingBinding(DirectExchange kingExchange, Queue kingQueue) {
        return BindingBuilder.bind(kingQueue).to(kingExchange).with(ROUTING_KEY);
    }


}
